import { App } from "vue";
import { useUserStore } from "@/store/user";

export const regPermission = (app: App<Element>) => {
  // 全局指令
  app.directive("permission", {
    // 生命周期
    mounted(el, binding) {
      const store = useUserStore();
      // 如果用户信息包含value就删除DOM元素
      if (!store.permissions.includes(binding.value)) {
        el.remove();
      }
    },
  });
};
